//
//  Utils.h
//  AnhChe
//
//  Created by Nguyen Cong Huy on 7/30/14.
//  Copyright (c) 2014 Nguyen Cong Huy. All rights reserved.
//

#define ENABLE_GOOGLE_ANALYTIC 1

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#define RGBACOLOR(r, g, b, a) [UIColor colorWithRed:((float)r/255.0f) green:((float)g/255.0f) blue:((float)b/255.0f) alpha:((float)a/255.0f)]
#define RGBCOLOR(r, g, b) RGBACOLOR(r, g, b, 255.0f)

#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname, accessorname) \
+ (classname *)accessorname\
{\
static classname *accessorname = nil;\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
accessorname = [[classname alloc] init];\
});\
return accessorname;\
}

@interface Utils : NSObject

+ (NSString*)convertToUnicodeFromUnicodeEscape:(NSString*)originString;
+ (int)getIntFromDictionary:(NSDictionary*)dictionary withKey:(NSString*)key;
+ (void)showErrorConnection;
+ (UIImage*)cropImage:(UIImage*)srcImage withCropRect:(CGRect)cropRect;
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;
+ (UIImage*)getHighLightImage;

#if ENABLE_GOOGLE_ANALYTIC
+ (void)sendTrackWithCategory:(NSString*)category action:(NSString*)action label:(NSString*)label value:(NSNumber*)value;
+ (void)sendTrackScreenViewName:(NSString*)screenName;
#endif

@end
